home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / utility / utilwb / mrjquote.lha / mrjQuote2.30 / ARexx / IndentAddSig.bed next >
Text File  |  1996-09-28  |  5KB  |  116 lines

  1. /* BED / mrjQuote email/news indenter and signature appender
  2.    ©1996 Mark Rigby-Jones for mrjsw
  3.    mark.rigby-jones@keble.oxford.ac.uk <*> http://users.ox.ac.uk/~kebl0206/
  4.  
  5. $VER: IndentAddSig.bed 1.1 (27.09.96)
  6.  
  7.    This script is intende for use when editing emails/news articles with
  8.    Blacks Editor. It can add an indent ("> " by default) to every non-empty
  9.    line from the cursor position downward. It can also use mrjQuote to
  10.    generate a random signature and append this to the buffer, together with
  11.    the required dashes "-- " and a little extra space.
  12.    Configuration:
  13.     Set QuotePort to the name of mrjQuote's ARexx port, and FileName and
  14.     SigName to the correct paths. Change DoSig from "load" to "yes" if you do
  15.     not want mrjQuote to be loaded if it isn't already (a new signature will
  16.     not be created in this case)
  17.    Usage:
  18.     Put this script in BED:ARexx/ and then call it as required:
  19.     "BED:Rexx/IndentAddSig"          - indent text and add signature
  20.     "BED:Rexx/IndentAddSig NOINDENT" - add signature only
  21.     "BED:Rexx/IndentAddSig NOSIG"    - indent text only                     */
  22.  
  23. QuotePort = "QUOTE"                            /* Change this if neccessary */
  24. FileName  = "mrjsw:Quote"                      /* Full path to mrjQuote     */
  25. SigName   = "Home:.signature"                  /* Full path to signature    */
  26. Indent    = "> "                               /* What to use as an indent  */
  27. DoSig     = "load"                             /* Default signature mode    */
  28.  
  29. Arg Opt .                                      /* Parse any argument        */
  30. If Opt = "NOINDENT" Then                       /* Indenting disabled        */
  31.     Indent=""
  32. If Opt = "NOSIG" Then                          /* Signature disabled        */
  33.     DoSig="no"
  34.  
  35. Options Results                                /* Enable return codes       */
  36.  
  37. If (Left(Address(),4) ~= "BED_") Then Do
  38.     Address "BED"                              /* If not called from doc    */
  39.     GetLastDoc                                 /*  get last doc edited      */
  40.     Address Value Result
  41.     End 
  42. BEDPort = Address()                            /* Get BED's port name       */
  43.  
  44. SetInputLock ON                                /* Lock GUI, gain access     */
  45. SetDisplayLock ON
  46.  
  47. Options FailAt 6                               /* Ignore warnings           */
  48. Signal On Syntax                               /* Ensure clean exit         */
  49.  
  50. SetStatusBar "Indenting text..."
  51.  
  52. GetFileInfo
  53. Lines = Word(RESULT,1)                         /* Get number of lines       */
  54. GetCursorPos
  55. Line = Word(RESULT,1)                          /* Get current line          */
  56. MoveSOL
  57.  
  58. Do i = Line To Lines                           /* For each remaining line   */
  59.     GetChar                                    /*  get info about line      */
  60.     If RC = 0 Then Do                          /*  if line is non-blank     */
  61.         Text '"'Indent'"'                      /*   add Indent to start     */
  62.         MoveSOL
  63.         If i = Lines Then Do
  64.             MoveEOL                            /*   if it's the last line   */
  65.             InsertLine                         /*    insert an extra line   */
  66.             End
  67.         End
  68.     MoveDown                                   /*  move to next line        */
  69.     End
  70.  
  71. InsertLine                                     /* Add an extra blank line   */
  72.  
  73. If DoSig = "no" Then Do                        /* If not to do  signature   */
  74.     SetDisplayLock OFF                         /*  unlock BED               */
  75.     SetInputLock OFF
  76.     Exit                                       /*  and exit the script      */
  77.     End
  78.  
  79. SetStatusBar "Generating Signature..."
  80.  
  81. If (~Show(P,QuotePort) & DoSig="load") Then Do /* If mrjQuote isn't loaded  */
  82.     Address "COMMAND"
  83.     'Run >NIL: "'FileName'" CDITY AREXX QUIET' /*  then run it              */
  84.     WaitForPort QuotePort                      /*  and wait for it to load  */
  85.     End
  86.  
  87. If Show(P,QuotePort) Then Do                   /* If mrjQuote is running    */
  88.     Address Value QuotePort
  89.     Sig                                        /*  create a random sig      */
  90.     End
  91.  
  92. Address Value BEDPort
  93.  
  94. SetBookMark 0
  95. InsertFile '"'SigName'"'                       /* Append signature file     */
  96. MoveBookMark 0
  97. ClearBookMark 0
  98.                                             
  99. InsertLine                                     /* Insert blank line         */
  100. If Lines > 1 Then                              /* " if file non-empty       */
  101.     InsertLine
  102. Text "-- "                                     /* Insert signature dashes   */  
  103. InsertLine
  104. MoveUp 3                                       /* Move cursor back up       */
  105.  
  106. SetDisplayLock OFF                             /* Unlock BED                */
  107. SetInputLock OFF
  108. Exit
  109.  
  110. Syntax:                                        /* If there's an error       */
  111. SetStatusBar '"Error, line 'SIGL' : 'ErrorText(RC)'"'
  112. Address Value BEDPort                          /* ^display details          */
  113. SetDisplayLock OFF                             /*  and unlock GoldEd        */
  114. SetInputLock OFF
  115. Exit
  116.